// 使用 canvas 绘制像素风格的 LOGO
const drawLogo = (canvas, ctx) => {
  // 设置画布大小
  canvas.width = 200
  canvas.height = 200

  // 背景色
  ctx.fillStyle = '#2c3e50'
  ctx.fillRect(0, 0, 200, 200)

  // 像素文字 - "木"
  const wood = [
    [0,0,1,0,0],
    [0,0,1,0,0],
    [1,1,1,1,1],
    [0,0,1,0,0],
    [0,0,1,0,0],
    [0,1,1,1,0],
    [1,0,1,0,1]
  ]

  // 像素文字 - "石"
  const stone = [
    [0,1,1,1,0],
    [1,0,1,0,0],
    [0,0,1,0,0],
    [1,1,1,1,1],
    [0,0,1,0,0],
    [0,0,1,0,0],
    [1,1,1,1,1]
  ]

  // 绘制像素
  const drawPixels = (pattern, startX, startY, size) => {
    ctx.fillStyle = '#ffffff'
    pattern.forEach((row, y) => {
      row.forEach((pixel, x) => {
        if (pixel) {
          ctx.fillRect(
            startX + x * size,
            startY + y * size,
            size - 1,
            size - 1
          )
        }
      })
    })
  }

  // 绘制两个字
  drawPixels(wood, 40, 60, 10)  // 木
  drawPixels(stone, 110, 60, 10) // 石

  // 添加圆角边框效果
  ctx.strokeStyle = '#ffffff'
  ctx.lineWidth = 4
  ctx.beginPath()
  ctx.roundRect(10, 10, 180, 180, 20)
  ctx.stroke()
}

module.exports = {
  drawLogo
}
